(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 9.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[      5009,        141]
NotebookOptionsPosition[      4728,        127]
NotebookOutlinePosition[      5071,        142]
CellTagsIndexPosition[      5028,        139]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
 RowBox[{
  RowBox[{"EstimateLocation", "[", "data_", "]"}], " ", ":=", 
  RowBox[{"(", 
   RowBox[{
    RowBox[{"source", " ", "=", " ", 
     RowBox[{"{", 
      RowBox[{"0", ",", "0"}], "}"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"fit", "=", 
     RowBox[{"NonlinearModelFit", "[", 
      RowBox[{"data", ",", 
       RowBox[{"Norm", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"x", ",", "y"}], "}"}], "-", 
         RowBox[{"{", 
          RowBox[{"x0", ",", "y0"}], "}"}]}], "]"}], ",", 
       RowBox[{"{", 
        RowBox[{"x0", ",", "y0"}], "}"}], ",", 
       RowBox[{"{", 
        RowBox[{"x", ",", "y"}], "}"}], ",", " ", 
       RowBox[{"Weights", "\[Rule]", 
        RowBox[{"1", "/", 
         RowBox[{
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "3"}], "]"}], "]"}], "^", "2"}]}]}]}], 
      "]"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"ellipsoid", "=", 
     RowBox[{"fit", "[", 
      RowBox[{"\"\<ParameterConfidenceRegion\>\"", ",", 
       RowBox[{"ConfidenceLevel", "\[Rule]", "0.95"}]}], "]"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"solution", "  ", "=", " ", 
     RowBox[{
      RowBox[{
      "fit", "[", "\"\<ParameterConfidenceIntervalTableEntries\>\"", "]"}], 
      "[", 
      RowBox[{"[", 
       RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"Graphics", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"Opacity", "[", "0.2", "]"}], ",", 
        RowBox[{"EdgeForm", "[", 
         RowBox[{"Opacity", "[", "0.75", "]"}], "]"}], ",", "White", ",", 
        RowBox[{
         RowBox[{
          RowBox[{"Disk", "[", 
           RowBox[{
            RowBox[{"Most", "[", "#", "]"}], ",", 
            RowBox[{"Last", "[", "#", "]"}]}], "]"}], "&"}], "/@", "data"}], 
        ",", 
        RowBox[{"Opacity", "[", "1", "]"}], ",", "Red", ",", "ellipsoid", ",", 
        RowBox[{"PointSize", "[", "0.0125", "]"}], ",", "Blue", ",", 
        RowBox[{"Point", "[", "source", "]"}], ",", "Red", ",", 
        RowBox[{"Point", "[", "solution", "]"}], ",", 
        RowBox[{"PointSize", "[", "0.0083", "]"}], ",", "White", ",", 
        RowBox[{
         RowBox[{
          RowBox[{"Point", "@", 
           RowBox[{"Most", "[", "#", "]"}]}], " ", "&"}], "/@", "data"}]}], 
       "}"}], ",", 
      RowBox[{"Background", "\[Rule]", "Black"}], ",", 
      RowBox[{"ImageSize", "\[Rule]", "600"}]}], "]"}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"Return", "[", "solution", "]"}], ";"}], ")"}]}]], "Input",
 CellChangeTimes->{{3.609308870343686*^9, 3.609308961165881*^9}, {
  3.60960770376698*^9, 3.6096077329416485`*^9}, {3.6096078143023024`*^9, 
  3.6096078847353306`*^9}, {3.609778220829998*^9, 3.6097782230671263`*^9}, {
  3.6097788532311697`*^9, 3.6097790279781647`*^9}, {3.609779311057356*^9, 
  3.60977932022688*^9}, {3.609779891114533*^9, 3.609779944577591*^9}, {
  3.609780521779605*^9, 3.609780528809007*^9}}],

Cell[BoxData[
 RowBox[{"\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"dat", " ", "=", " ", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"-", "1.91373"}], ",", 
         RowBox[{"-", "0.799904"}], ",", "2.04001"}], "}"}], ",", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"-", "0.935453"}], ",", 
         RowBox[{"-", "0.493735"}], ",", "0.959304"}], "}"}], ",", 
       RowBox[{"{", 
        RowBox[{"0.630964", ",", 
         RowBox[{"-", "0.653075"}], ",", "0.728477"}], "}"}], ",", 
       RowBox[{"{", 
        RowBox[{"0.310857", ",", 
         RowBox[{"-", "0.018258"}], ",", "0.301885"}], "}"}], ",", 
       RowBox[{"{", 
        RowBox[{"0.0431084", ",", "1.25321", ",", "1.19012"}], "}"}]}], 
      "}"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"EstimateLocation", "[", "dat", "]"}]}], "*)"}], 
  "\[IndentingNewLine]", 
  RowBox[{"Save", "[", 
   RowBox[{"\"\<functions.m\>\"", ",", 
    RowBox[{"{", "EstimateLocation", "}"}]}], "]"}]}]], "Input",
 CellChangeTimes->{{3.6097799610585337`*^9, 3.609779967196885*^9}, {
  3.609780531270148*^9, 3.60978058551025*^9}}]
},
WindowSize->{1904, 945},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
FrontEndVersion->"9.0 for Microsoft Windows (64-bit) (January 25, 2013)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[557, 20, 3009, 73, 152, "Input"],
Cell[3569, 95, 1155, 30, 92, "Input"]
}
]
*)

(* End of internal cache information *)
